const Router = require('@koa/router');
const swaggerSpec = require('../config/swagger');
const authRoutes = require('./auth.routes');
const userRoutes = require('./user.routes');
const permissionRoutes = require('./permission.routes');
const deviceRoutes = require('./device.routes');
const paymentRoutes = require('./payment.routes');
const orderRoutes = require('./order.routes');
const applicationRoutes = require('./application.routes');
const mapServiceRoutes = require('./mapService.routes');
const campusAccountRoutes = require('./campusAccount.routes');
const pointRuleRoutes = require('./pointRule.routes');
const pointTransactionRoutes = require('./pointTransaction.routes');
const memberLevelRoutes = require('./memberLevel.routes');
const miniProgramRoutes = require('./miniProgram.routes');
const wechatRoutes = require('./wechat.routes');
const cacheRoutes = require('./cache.routes');
const queueRoutes = require('./queue.routes');
const notificationRoutes = require('./notification.routes');
const fileRoutes = require('./file.routes');

const router = new Router();

// Health check endpoint
router.get('/health', (ctx) => {
  ctx.body = {
    status: 'success',
    message: 'Server is running',
    timestamp: new Date()
  };
});

// Serve swagger spec
router.get('/swagger.json', (ctx) => {
  ctx.body = swaggerSpec;
});

// Welcome route
router.get('/', (ctx) => {
  ctx.body = {
    status: 'success',
    message: 'Welcome to ManageX API'
  };
});

// Register all routes
router.use(authRoutes.routes());
router.use(userRoutes.routes());
router.use(permissionRoutes.routes());
router.use(deviceRoutes.routes());
router.use(paymentRoutes.routes());
router.use(orderRoutes.routes());
router.use(applicationRoutes.routes());
router.use(mapServiceRoutes.routes());
router.use(campusAccountRoutes.routes());
router.use(pointRuleRoutes.routes());
router.use(pointTransactionRoutes.routes());
router.use(memberLevelRoutes.routes());
router.use(miniProgramRoutes.routes());
router.use(wechatRoutes.routes());
router.use(cacheRoutes.routes());
router.use(queueRoutes.routes());
router.use(notificationRoutes.routes());
router.use(fileRoutes.routes());

module.exports = router; 